/*-----------------------------------------------------------------------------
	The contents of this file are subject to the Mozilla Public License
	Version 1.1 (the "License"); you may not use this file except in
	compliance with the License. You may obtain a copy of the License at
	http://www.mozilla.org/MPL/
	
	Software distributed under the License is distributed on an "AS IS"
	basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
	License for the specific language governing rights and limitations
	under the License.
	
	The Original Code is Fever Framework code.
	
	The Initial Developer of the Original Code is Romain Ecarnot.
	Portions created by Initial Developer are Copyright (C) 2006
	the Initial Developer. All Rights Reserved.
	
	Contributor(s):
	
	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
-----------------------------------------------------------------------------*/

import fever.utils.Stringifier;

/**
 * FVL Metadata wrapper.
 *
 * @author Romain Ecarnot
 */
class fever.medias.video.VideoMetaData
{
	//-------------------------------------------------------------------------
	// Private properties
	//-------------------------------------------------------------------------
	
	private var _duration : Number;
	private var _width : Number;
	private var _height : Number;
	private var _videodatarate : Number;
	private var _audiodatarate : Number;
	private var _framerate : Number;
	private var _creationdate : Date;
	private var _filesize : Number;
	private var _videosize : Number;
	private var _audiosize : Number;
	private var _datasize : Number;
	private var _metadatacreator : String;
	private var _metadatadate : Date;
	
	
	//-------------------------------------------------------------------------
	// Public Properties
	//-------------------------------------------------------------------------
	
	public function get metadatadate() : Date { return _metadatadate; }
	public function get metadatacreator() : String { return _metadatacreator; }
	public function get datasize() : Number { return _datasize; }
	public function get audiosize() : Number { return _audiosize; }
	public function get videosize() : Number { return _videosize; }
	public function get filesize() : Number { return _filesize; }
	public function get creationdate() : Date { return _creationdate; }
	public function get framerate() : Number { return _framerate; }
	public function get audiodatarate() : Number { return _audiodatarate; }
	public function get videodatarate() : Number { return _videodatarate; }
	public function get height() : Number { return _height; }
	public function get width() : Number { return _width; }
	public function get duration() : Number { return _duration; }
	
	
	//-------------------------------------------------------------------------
	// Public API
	//-------------------------------------------------------------------------
	
	/**
	 * Creates {@link VideoMetaData} instance from .onMetatData NetStream callback.
	 */
	public static function create( metadata : Object ) : VideoMetaData
	{
		var data : VideoMetaData = new VideoMetaData();
		
		data._duration = parseInt( metadata.duration );
		data._width = metadata.width;
		data._height = metadata.height;
		data._videodatarate = metadata.videodatarate;
		data._audiodatarate = metadata.audiodatarate;
		data._framerate = metadata.framerate;
		data._creationdate = metadata.creationdate;
		data._filesize = metadata.filesize;
		data._videosize = metadata.videosize;
		data._audiosize = metadata.audiosize;
		data._datasize = metadata.datasize;
		data._metadatacreator = metadata.metadatacreator;
		data._metadatadate = metadata.metadatadate;
		
		return data;
	}
	
	
	/**
	 * Returns string representation.
	 */
	public function toString() : String
	{
		return Stringifier.parse( this );
	}
	
	
	//-------------------------------------------------------------------------
	// Private implementation
	//-------------------------------------------------------------------------
		
	/**
	 * Constructor.
	 */
	private function VideoMetaData()
	{
		
	}	
}